Skip to content

Load example data in one click - #26

Merged
Abson-dev merged 2 commits into
masterfrom
feat/example-data
Dec 1, 2026
Merged

Abson-dev merged 2 commits into
masterfrom
feat/example-data

Conversation

@Abson-dev

@Abson-dev Abson-dev commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

sdmApp is aimed at users with little R experience, but its first screen asked them to find raster files and an occurrence table before they could see anything. The package already ships example data: the Niakhar survey of Faidherbia albida and its predictors. They were only reachable by browsing the file choosers' "Examples" folder and loading the rasters and the table in two separate steps, with the right separator settings.

This PR adds a "Try with example data" button at the top of the Data Upload tab.

What it loads

  • Predictors: five bundled layers, bio1, bio4, bio12, bio15 and Elev (temperature, rainfall and elevation).
  • Occurrences: a reproducible sample (set.seed(1)) of 1,500 of the 9,258 Niakhar presence/absence points, with the coordinate and species columns already set. The sample keeps the demo responsive, since all points make random forests and tuning slow.
  • Previous projection layers, thinning and folds are reset, as when loading files, and a notification points to the next tabs.

Portable script

The R-Code tab writes the example with system.file("extdata", ..., package = "sdmApp") and the same seeded sample, never this machine's library path, so the generated script and HTML report run on any computer. Its checklist shows "example data".

Validation

  • Browser test (shinytest2, headless Chrome): the button appears and loads the data with its notification. A GLM fitted straight away maps suitability, with no R errors in the log.
  • Script reproduction: a new end-to-end test clicks the button, fits a GLM, checks that the script uses system.file() and contains no library path, then runs the script. It rebuilds the same 1,500 points and identical fold metrics.

Testing

  • test-app-script.R: new example-data test.
  • lintr::lint_package(): no lints. spelling: no errors.
  • devtools::test(): 103 tests, 527 expectations, 0 failed, 0 skipped. After merging master (with Measure the spatial sorting bias of cross-validation folds #25) into the branch, the affected tests were run again and pass: 5 script tests and 3 sorting-bias tests.

🤖 Generated with Claude Code

Abson-dev and others added 2 commits December 1, 2026 09:36
The Data Upload tab has a "Try with example data" button loading five
predictors and a reproducible sample of 1,500 Niakhar occurrences of
Faidherbia albida, so the workflow can be explored without one's own
files. The R-Code tab rebuilds them with system.file(), so the script
runs on any machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Abson-dev
Abson-dev merged commit 48ed26d into master Dec 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant